package com.gmall.rabbitmq.producer.controller;

import com.gmall.rabbitmq.config.DirectExchange_Queue_Config;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/directEx")
public class DirectExController {

    @Autowired
    RabbitTemplate rabbitTemplate;


    @GetMapping("/produce/sms")
    public String produceSMSMessage(){
        /**
         * String exchange 交换机
         * String routingKey 路由键
         * Object object 消息内容
         */
        rabbitTemplate.convertAndSend(
                DirectExchange_Queue_Config.DIRECT_EXCHANGE,
                DirectExchange_Queue_Config.DIRECT_EX_QUEUE_SMS_ROUTINGKEY
                ,"hello,world");
        return "OK";
    }
    @GetMapping("/produce/email")
    public String produceEmailMessage(){
        rabbitTemplate.convertAndSend(
                DirectExchange_Queue_Config.DIRECT_EXCHANGE,
                DirectExchange_Queue_Config.DIRECT_EX_QUEUE_EMAIL_ROUTINGKEY
                ,"hello,world");
        return "OK";
    }

    @GetMapping("/produce/qq")
    public String produceQQMessage(){
        rabbitTemplate.convertAndSend(
                DirectExchange_Queue_Config.DIRECT_EXCHANGE,
                DirectExchange_Queue_Config.DIRECT_EX_QUEUE_QQ_ROUTINGKEY
                ,"hello,world");


        return "OK";
    }


}
